<template>
  <div class="header-container">
    <div class="l-content">
         <el-button style="margin-right:20px;" @click="handleMenu" icon="el-icon-menu" size="mini"></el-button>
         <el-breadcrumb separator="/">
            <el-breadcrumb-item v-for="item in tabsList" :key="item.path" :to="{ path: item.path }">{{item.label}}</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="r-content">
        <el-dropdown @command="handleClick" slot="dropdown">
            <span class="el-dropdown-link">
                <img  v-if="photo" class="user" src="../assets/images/头像.jpg" alt="">
                <img v-else  class="user" src="../assets/images/user.png" />
            </span>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>个人中心</el-dropdown-item>
                <el-dropdown-item command='cancel'>退出</el-dropdown-item>

            </el-dropdown-menu>
        </el-dropdown>
    </div>
  </div>
</template>

<script>
import {mapState} from 'vuex'
import Cookie from 'js-cookie'
export default {
    data() {
        return {
            
        }
    },
    methods: {
        handleMenu(){
            this.$store.commit('tab/collapseMenu')
        },
        handleClick(command){
            if (command === 'cancel') {
                // 登出
                Cookie.remove('token')  //清除cookie中的token
                Cookie.remove('menu')   //清除cookie中的menu
                this.$router.push({name:'login'})
            }
        }
    },
    computed:{
        ...mapState('tab',['tabsList']),
        photo(){
            var abb = this.$store.state.tab.menu
            if (abb.length > 2) {
                return true
            }else{
                return false
            }
        }
    },
    mounted(){
        console.log('111111111',this.tabsList)
    }
}
</script>

<style lang='less' scoped>
    .header-container{
        background-color: #333;
        height: 60px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-left: 20px;
        .text{
            color: white;
            font-size: 14px;
            margin-left: 10px;
        }
        .r-content{
            .el-dropdown-link{
                .user{
                width: 40px;
                height: 40px;
                border-radius: 50%;
                margin-right: 10px;
                }
            }
        }
        .l-content{
            display: flex;
            align-items: center;
            /deep/.el-breadcrumb__item{
            .el-breadcrumb__inner{
                    font-weight: normal;
                    &.is-link{
                        color: #666;
                    }
                }
                &:last-child{
                    .el-breadcrumb__inner{
                        color: white;
                    }
                }
            }
        }
    }
</style>